package com.aca.tool;

public class Pager {
    private int pageCur; //当前页
    private int pageSize;//页大小
    private int totalPage;//总页数
    private int totalSize;//记录总数
    private boolean hasFirst;//是否有首页
    private boolean hasPre;//是否有前一页
    private boolean hasNext;//是否有下一页
    private boolean hasLast;//是否有尾页

    //构造方法
    public Pager(int pageCur,int pageSize,int totalSize){
        this.pageCur=pageCur;
        this.pageSize=pageSize;
        this.totalSize=totalSize;
    }
    public int getPageCur(){
        return pageCur;
    }

    public void setPageCur(int pageCur) {
        this.pageCur = pageCur;
    }

    public int getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(int totalSize) {
        this.totalSize = totalSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageSize() {
        return pageSize;
    }
    public int getTotalPage(){
        totalPage=totalSize/pageSize;
        if(totalSize%pageSize!=0) {
            totalPage++;
        }
        return totalPage;
    }


    public void setTotalPage(int totalPage){
        this.totalPage=totalPage;
    }



    public void setHasFirst(boolean hasFirst) {
        this.hasFirst = hasFirst;
    }

    public boolean isHasFirst() {
        //若当前页为第一页，则无首页
        if(pageCur==1)
            return false;
        else
            return true;
    }
    public boolean isHasPre() {
        if(this.isHasFirst())
            return true;
        else
            return false;

    }

    public void setHasPre(boolean hasPre) {
        this.hasPre = hasPre;
    }

    public void setHasLast(boolean hasLast) {
        this.hasLast = hasLast;
    }


    public boolean isHasLast() {
        if(pageCur==this.getTotalPage()||this.totalPage==0)
            return false;
        else
            return true;
    }

    public boolean isHasNext() {
        //若有首页，则当前页不是最后一页
        if(isHasLast())
            return true;
        else
            return false;
    }

    public void setHasNext(boolean hasNext) {
        this.hasNext = hasNext;
    }
}
